分类表：Categories

字段	类型	允许 Null	无符号	自增	索引	默认值
id(编号)	integer	NO	YES	YES	PRIMARY	-
name(名称)	varchar	NO	-	-	-	-
rank(排序)	integer	NO	YES	-	-	1
课程表：Courses

字段	类型	允许 Null	无符号	自增	索引	默认值
id(编号)	integer	NO	YES	YES	PRIMARY	-
categoryId(分类 id)	integer	NO	YES	-	INDEX	-
userId(用户 id)	integer	NO	YES	-	INDEX	-
name(名称)	varchar	NO	-	-	-	-
image(图片)	varchar	-	-	-	-	-
recommended(推荐)	boolean	NO	-	-	INDEX	false
introductory(入门)	boolean	NO	-	-	INDEX	false
content(内容)	text	-	-	-	-	-
likesCount(点赞数)	integer	NO	YES	-	-	0
chaptersCount(章节数)	integer	NO	YES	-	-	0
章节表：Chapters

字段	类型	允许 Null	无符号	自增	索引	默认值
id(编号)	integer	NO	YES	YES	PRIMARY	-
courseId(课程 id)	integer	NO	YES	-	INDEX	-
title(标题)	varchar	NO	-	-	-	-
content(内容)	text	-	-	-	-	-
video(视频地址)	varchar	-	-	-	-	-
rank(排序)	integer	NO	-	-	-	1
用户表：Users

字段	类型	允许 Null	无符号	自增	索引	默认值	备注
id(编号)	integer	NO	YES	YES	PRIMARY	-
email(邮箱)	varchar	NO	-	-	UNIQUE	-
username(用户名)	varchar	NO	-	-	UNIQUE	-
password(密码)	varchar	NO	-	-	-	-
nickname(昵称)	varchar	NO	-	-	-	-
sex(性别)	tinyint	NO	-	-	-	2	0-男，1-女，2-未选择
avatar(头像)	varchar	-	-	-	-	-
company(公司)	varchar	-	-	-	-	-
introduce(自我介绍)	text	-	-	-	-	-
role(用户组)	tinyint	NO	YES	-	INDEX	0	0-普通用户，100-管理员
点赞表：Likes

字段	类型	允许 Null	无符号	自增	索引
id(编号)	integer	NO	YES	YES	PRIMARY
courseId(课程 id)	integer	NO	YES	-	INDEX
userId(用户 id)	integer	NO	YES	-	INDEX
设置表：Settings

字段	类型	允许 Null	无符号	自增	索引
id(编号)	integer	NO	YES	YES	PRIMARY
name(项目名称)	varchar	-	-	-	-
icp(备案号)	varchar	-	-	-	-
copyright(版权信息)	varchar	-	-	-	-


-- MySQL Workbench Synchronization
-- Generated: 2025-01-31 09:14
-- Model: New Model
-- Version: 1.0
-- Project: Name of the project
-- Author: user

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;

CREATE TABLE IF NOT EXISTS `mydb`.`Categories` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  `rank` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `mydb`.`Articles` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `mydb`.`Courses` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `categoryid` INT(10) UNSIGNED NOT NULL,
  `name` VARCHAR(255) NOT NULL,
  `image` VARCHAR(255) NULL DEFAULT NULL,
  `recommended` TINYINT(4) NOT NULL DEFAULT 0,
  `introductory` TINYINT(4) NOT NULL DEFAULT 0,
  `content` TEXT NULL DEFAULT NULL,
  `likesCount` INT(10) UNSIGNED NOT NULL DEFAULT 0,
  `chaptersCount` INT(10) UNSIGNED NOT NULL DEFAULT 0,
  `categoriesId` INT(10) UNSIGNED NOT NULL,
  `usersId` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Courses_Categories_idx` (`categoriesId` ASC) VISIBLE,
  INDEX `fk_Courses_Users1_idx` (`usersId` ASC) VISIBLE,
  CONSTRAINT `fk_Courses_Categories`
    FOREIGN KEY (`categoriesId`)
    REFERENCES `mydb`.`Categories` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Courses_Users1`
    FOREIGN KEY (`usersId`)
    REFERENCES `mydb`.`Users` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `mydb`.`Settings` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  `icp` VARCHAR(255) NOT NULL,
  `copyright` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `mydb`.`Chapters` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `courseld` INT(10) UNSIGNED NOT NULL,
  `title` VARCHAR(255) NOT NULL,
  `content` TEXT NULL DEFAULT NULL,
  `video` VARCHAR(45) NOT NULL,
  `rank` INT(10) UNSIGNED NOT NULL,
  `coursesId` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Chapters_Courses1_idx` (`coursesId` ASC) VISIBLE,
  CONSTRAINT `fk_Chapters_Courses1`
    FOREIGN KEY (`coursesId`)
    REFERENCES `mydb`.`Courses` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `mydb`.`Llkes` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `courseid` INT(10) UNSIGNED NOT NULL,
  `userid` INT(10) UNSIGNED NOT NULL,
  `coursesId` INT(10) UNSIGNED NOT NULL,
  `usersId` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Llkes_Courses1_idx` (`coursesId` ASC) VISIBLE,
  INDEX `fk_Llkes_Users1_idx` (`usersId` ASC) VISIBLE,
  CONSTRAINT `fk_Llkes_Courses1`
    FOREIGN KEY (`coursesId`)
    REFERENCES `mydb`.`Courses` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Llkes_Users1`
    FOREIGN KEY (`usersId`)
    REFERENCES `mydb`.`Users` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE TABLE IF NOT EXISTS `mydb`.`Users` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `email` VARCHAR(255) NOT NULL,
  `password` VARCHAR(255) NOT NULL,
  `password` VARCHAR(255) NOT NULL,
  `nickname` VARCHAR(255) NOT NULL,
  `avatar` VARCHAR(45) NOT NULL,
  `sex` VARCHAR(45) NOT NULL,
  `compnay` VARCHAR(45) NULL DEFAULT NULL,
  `introduce` TEXT NULL DEFAULT NULL,
  `role` TINYINT(4) NULL DEFAULT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;